<template>
	<view class="home">
		<view class="content" v-for="v in houseMag" :key="v.id">
			<view @click="house(v.name)">
				<view class="content-header">
					<span>默认</span>
					<text>{{v.community}}</text>
					<view class="type">
						<span>{{v.houseState}}</span>
					</view>
				</view>
				<view class="content-body">
					<view class="content-body-title">
						<text>房间号</text>
						<text>业主</text>
						<text>房屋状态</text>
					</view>
					<view class="content-body-msg">
						<text>{{v.room}}</text>
						<text>{{v.name}}</text>
						<text>{{v.houseState}}</text>
					</view>
				</view>
			</view>
		</view>
		<navigator url="/pages/myHouse/addHouse/addHouse" hover-class="navigator-hover">
			<button class="button" type="primary">
				<uni-icons type="plusempty" size="20"></uni-icons> <text class="button-text">添加房屋</text>
			</button>
		</navigator>
	</view>
</template>

<script>
	import {
		http
	} from "../../../utils/http.js"
	export default {
		data() {
			return {
				houseMag: [],

			};
		},
		methods: {
			house(v) {
				uni.navigateTo({
					url: '../../confirmHouseMag/confirmHouseMag?name=' + v
				});
			},
			getData() {
				http({
					url: "/householdManagement/list",
					method: "get",
				}).then((res) => {
					if (res.code == 0) {
						this.houseMag = res.data.list;
					} else {
						console.log("数据接收失败")
					}

				})

			},
		},
		onLoad() {
			this.getData()
		},
	}
</script>

<style lang="less">
	.home {
		padding: 40rpx;
		display: flex;
		flex-direction: column;

		.content {
			margin-bottom: 16px;
			height: 332rpx;
			border-radius: 4px;
			border: 1px solid #cbcbcb;
			display: flex;
			flex-direction: column;
			justify-content: center;

			.content-header {
				width: 632rpx;
				height: 112rpx;
				border-bottom: 1px solid #cbcbcb;
				display: flex;
				justify-content: space-evenly;
				align-items: center;

				span {
					font-size: 28rpx;
					width: 78rpx;
					height: 50rpx;
					border-radius: 4px;
					color: aliceblue;
					display: flex;
					justify-content: center;
					align-items: center;
					background-color: #006eff;
				}

				.type {
					span {
						width: 134rpx;
						background-color: #d4f6e3;
						color: #44d885;
					}
				}
			}

			.content-body {
				flex: 1;
				display: flex;

				.content-body-title {
					margin-left: 16px;
					width: 132rpx;
					display: flex;
					flex-direction: column;
					justify-content: center;
					color: #ababab;
					line-height: 56rpx;
					height: 100%;
				}

				.content-body-msg {
					margin-left: 16px;
					display: flex;
					flex-direction: column;
					justify-content: center;
					line-height: 56rpx;
					height: 100%;
				}
			}
		}

		.button {
			width: 100%;
			color: white;
		}
	}
</style>
